Intro

Basic analysis of Vancouver weather patterns:

Data Collection

Data is collected from Govt of Canada website:

  1. search: http://climate.weather.gc.ca/historical_data/search_historic_data_e.html
  2. select station of interest by searching for stations with ‘vancouver’ at start of name
  3. select ‘daily’, select ‘year’ (note that year shown is end of period data is available for; most stations have very little data)
  4. ‘Go’ goes to a page to access results for year

(process is automated in ‘van-weather-import.R’)

## [1] "Winter" "Spring" "Summer" "Fall"

Earliest date: 1970-01-01
Most recent date: 2021-07-02
`

Check data structure and summary:

## spec_tbl_df [18,810 × 11] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
##  $ Date        : Date[1:18810], format: "1970-01-01" "1970-01-02" ...
##  $ Year        : Factor w/ 52 levels "1970","1971",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ Month       : Factor w/ 12 levels "1","2","3","4",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ Day         : num [1:18810] 1 2 3 4 5 6 7 8 9 10 ...
##  $ Season      : Factor w/ 4 levels "Winter","Spring",..: 1 1 1 1 1 1 1 1 1 1 ...
##  $ Season.Yr   : num [1:18810] 1970 1970 1970 1970 1970 1970 1970 1970 1970 1970 ...
##  $ Max.Temp    : num [1:18810] 6.1 2.2 5 2.8 1.7 5.6 3.3 4.4 7.2 5.6 ...
##  $ Min.Temp    : num [1:18810] -1.7 0 -1.7 -3.3 -2.8 -1.7 -3.3 0 2.8 -2.8 ...
##  $ Mean.Temp   : num [1:18810] 2.2 1.1 1.7 -0.3 -0.6 2 0 2.2 5 1.4 ...
##  $ Total.Precip: num [1:18810] 0 1 0.5 0 0 0 0 4.6 6.6 0.5 ...
##  $ Station     : chr [1:18810] "VANCOUVER INT'L A" "VANCOUVER INT'L A" "VANCOUVER INT'L A" "VANCOUVER INT'L A" ...
##  - attr(*, "spec")=
##   .. cols(
##   ..   Date = col_date(format = ""),
##   ..   Year = col_double(),
##   ..   Month = col_double(),
##   ..   Day = col_double(),
##   ..   Season = col_character(),
##   ..   Season.Yr = col_double(),
##   ..   Max.Temp = col_double(),
##   ..   Min.Temp = col_double(),
##   ..   Mean.Temp = col_double(),
##   ..   Total.Precip = col_double(),
##   ..   Station = col_character()
##   .. )
##       Date                 Year           Month           Day       
##  Min.   :1970-01-01   1972   :  366   1      :1612   Min.   : 1.00  
##  1st Qu.:1982-11-16   1976   :  366   3      :1612   1st Qu.: 8.00  
##  Median :1995-10-02   1980   :  366   5      :1612   Median :16.00  
##  Mean   :1995-10-02   1984   :  366   7      :1583   Mean   :15.73  
##  3rd Qu.:2008-08-16   1988   :  366   8      :1581   3rd Qu.:23.00  
##  Max.   :2021-07-02   1992   :  366   10     :1581   Max.   :31.00  
##                       (Other):16614   (Other):9229                  
##     Season       Season.Yr       Max.Temp        Min.Temp      
##  Winter:4661   Min.   :1970   Min.   :-8.70   Min.   :-15.200  
##  Spring:4784   1st Qu.:1982   1st Qu.: 8.90   1st Qu.:  2.800  
##  Summer:4724   Median :1995   Median :13.30   Median :  6.800  
##  Fall  :4641   Mean   :1995   Mean   :13.83   Mean   :  6.699  
##                3rd Qu.:2008   3rd Qu.:19.00   3rd Qu.: 11.300  
##                Max.   :2021   Max.   :34.40   Max.   : 22.400  
##                               NA's   :67      NA's   :60       
##    Mean.Temp       Total.Precip      Station         
##  Min.   :-11.50   Min.   : 0.000   Length:18810      
##  1st Qu.:  6.00   1st Qu.: 0.000   Class :character  
##  Median : 10.00   Median : 0.000   Mode  :character  
##  Mean   : 10.29   Mean   : 3.214                     
##  3rd Qu.: 15.10   3rd Qu.: 3.600                     
##  Max.   : 28.40   Max.   :91.600                     
##  NA's   :69       NA's   :54
  • Looks like quite a few NAs for temp and precip; as long as they are spread out, shouldn’t be a problem

Check Data Relationships

  • uses PerformanceAnalytics package

  • Looks like temperatures are highly correlated and precipation has weak negative correlation with temperate (colder weather slightly more associated with rain)

Precipitation

Monthly precipitation data: Averages

Data by Month - ranked in order of highest precipitation

Monthly Preciptiation: Ranges

Current Month Precipitation

Monthly Comparison YoY

For each month, what has been the pattern in precipitation over the years?

Seasonal Precipitation

Season definitions:

  • Winter: Dec, Jan, Feb
  • Spring: Mar, Apr, May
  • Summer: Jun, Jul, Aug
  • Fall: Sep, Oct, Nov

Note: the year for a winter season is applied to year at end of season. So winter from Dec 2018 to Feb 2019 is considered winter of 2019.

Seasonal Precipitation Annual Ranking

  • Need separate charts because each season ranked individually
  • Line = median

Temperature

Check for missing data

  • Something to watch for if there are suspicious results for years with higher NAs.
  • Probbaly not going to be enough cause to throw whole year out. Could do some imputation of missing values, such as using averages, but probably not worth it.

Ave. Annual Temperature

  • 1985 looks like an outlier, although doesn’t look like any NAs based on info above.
  • Overall, appears to be a legitimate trend in rising temperatures

Years Ranked by Average Daily Temp

Linear model of annual temperature change

## 
## Call:
## lm(formula = mean.mean ~ ynum, data = vw.temp.yr)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1.11837 -0.35274 -0.08088  0.36937  0.97701 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -40.987746   9.420792  -4.351 6.87e-05 ***
## ynum          0.025708   0.004722   5.444 1.66e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4964 on 49 degrees of freedom
## Multiple R-squared:  0.3769, Adjusted R-squared:  0.3642 
## F-statistic: 29.64 on 1 and 49 DF,  p-value: 1.659e-06

Model interpretation:

  • Average daily temperature changing 0.0257081 degrees each yr.
  • P-value for statistical significance: 1.6594794^{-6}
  • Temperature change is statistically significant over this period

Look at Average Daily Maximum and Minimums for each Year

Linear modelling for max and min

## 
## Call:
## lm(formula = mean.max ~ ynum, data = vw.temp.yr)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.93114 -0.31913  0.04793  0.35363  1.05197 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -27.048385   9.663318  -2.799 0.007310 ** 
## ynum          0.020496   0.004844   4.232 0.000101 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.5092 on 49 degrees of freedom
## Multiple R-squared:  0.2676, Adjusted R-squared:  0.2527 
## F-statistic: 17.91 on 1 and 49 DF,  p-value: 0.0001014

Model interpretation:

  • Average daily MAX temperature changing 0.0204959 degrees each yr.
  • P-value for statistical significance: 1.0137692^{-4}
  • Temperature change is statistically significant over this period
## 
## Call:
## lm(formula = mean.min ~ ynum, data = vw.temp.yr)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1.30263 -0.31189  0.01655  0.40452  1.11209 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -54.893664   9.779701  -5.613 9.18e-07 ***
## ynum          0.030880   0.004902   6.300 8.07e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.5153 on 49 degrees of freedom
## Multiple R-squared:  0.4475, Adjusted R-squared:  0.4362 
## F-statistic: 39.68 on 1 and 49 DF,  p-value: 8.07e-08

Model interpretation:

  • Average daily MIN temperature changing 0.0308802 degrees each yr.
  • P-value for statistical significance: 8.069551^{-8}
  • Temperature change is statistically significant over this period

Monthly average temperature

Monthly Temperatures: Ranges

Monthly Temp. Comparison YoY

For each month, what has been the pattern in ave. temperature over the years?

Seasonal Temperatures

Season definitions:

  • Winter: Dec, Jan, Feb
  • Spring: Mar, Apr, May
  • Summer: Jun, Jul, Aug
  • Fall: Sep, Oct, Nov

Note: the year for a winter season is applied to year at end of season. So winter from Dec 2018 to Feb 2019 is considered winter of 2019.